package com.bgybmi.entity;

public class CommonStatic {
	
	/**
	 * @description if mul param we will create a new method to create this function
	 * @param table
	 * @param user
	 * @return select * from xxx where param=?
	 */
	public static String listByUser(String table,String param){
		return "select * from " +table+ " where "+param+"=?";
	}
	
	public static String listByParam(String table,String paramfiled){
		return "select * from " +table+ " where "+paramfiled+"=?";
	}
	/**
	 * @param table
	 * @param userfiled
	 * @param condition
	 * @return sql:"select * from" +table+ " where "+userfiled+"=? and "+condition+"?;
	 */
	public static String listAllByContitionAndUser(String table, String condition, String userfiled) {
		// TODO Auto-generated method stub
		return "select * from " +table+ " where "+userfiled+"=? and "+condition;
	}
	
	public static String listAll(String table){
		return "select * from " +table;
	}
	
	/**
	 * @author hecore
	 *  mul param if we need. 
	 *  format:(String user, Object... paras) 
	 *  apply:
	 *  for (int i=0; i<paras.length; i++) {
			pst.setObject(i + 1, paras[i]);
		}
	 */
	
	public static String getByParam(String table,String param){
		return "select * from " +table+ " where "+param+"=?";
	}
	
	public static String deleteByParam(String table,String param){
		return "delete from " +table+ " where "+param+"=?";
	}
	
	
	public static void main(String[] args) {
		String s=CommonStatic.listAllByContitionAndUser("bx","hecore","A>1 and A<2");
		//String s=CommonStatic.getByParam("bx", "ss");
		System.out.println(s);
	}
}
